import{reactive,toRefs,computed,watch} from 'vue'
function HookCount(){
    const state = reactive({
        count:1,
        addCount(){
            state.count++
        },
        double:computed(()=>{
            return state.count*2
        })
    })
    
    /* watch(state,()=>{
        console.log(state.count)
        document.title = state.count;
    }) */
    /* 监听state中某一个值 */
    watch(()=>state.count,()=>{
        console.log(state.count)
        document.title = state.count;
    })
    const refState = toRefs(state);
    return refState
}
export default HookCount;